<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>事件修饰符</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
  </head>
  <body>
    <div id="app">
      <div>{{num}}</div>
      <div v-on:click="handle1">
        <button v-on:click.stop="handle2">点击</button>
      </div>
      <div>
        <a href="http://www.baidu.com" v-on:click.prevent="handle3">百度</a>
      </div>
    </div>

    <script>
      var vm = new Vue({
        el: '#app',
        data: {
          num: 0,
        },
        methods: {
          handle1: function () {
            console.log('handle1');
            this.num++;
          },
          handle2: function () {
            console.log('handle2');
            this.num++;
          },
          handle3: function () {
            console.log(this);
          },
        },
      });
    </script>
  </body>
</html>
